#!/usr/bin/env python

import wx
import component

class Main(component.Interactor):
    '''Main class
    
    @author Julot <andy.julot@gmail.com>
    @since Saturday, January 14, 2012. 09:04 AM'''
    
    def bind(self):
        super(Main, self).bind()
        
        view = self.view
        menu = view.MenuBar
        tool = view.ToolBar
        
        view.Bind(wx.EVT_MENU, self.browse, menu.file.browse)
        view.Bind(wx.EVT_MENU, self.mold, menu.file.mold)
        view.Bind(wx.EVT_MENU, self.setupPrinter, menu.file.printerSettings)
        view.Bind(wx.EVT_MENU, self.close, menu.file.close)
        view.Bind(wx.EVT_MENU, self.showAbout, menu.help.about)
        
        view.Bind(wx.EVT_MENU, self.browse, tool.browse)
        view.Bind(wx.EVT_MENU, self.mold, tool.mold)
        view.Bind(wx.EVT_MENU, self.setupPrinter, tool.printerSettings)
        view.Bind(wx.EVT_MENU, self.close, tool.close)
        view.Bind(wx.EVT_MENU, self.showAbout, tool.about)
    
        view.Bind(wx.EVT_LIST_ITEM_SELECTED, self.preview,
                  view.names)
        view.Bind(wx.EVT_COMBOBOX, self.preset, view.options.preset)
        
    def mold(self, event):
        event.Skip()
        self.presenter.mold()
    
    def browse(self, event):
        self.presenter.browse()
        event.Skip()
    
    def preview(self, event):
        self.presenter.preview(event.m_item.Text)
        event.Skip()
    
    def close(self, event):
        self.presenter.close()
        event.Skip()
    
    def showAbout(self, event):
        self.presenter.showAbout()
        event.Skip()
    
    def preset(self, event):
        self.presenter.preset(event.ClientData)
        event.Skip()
        
    def setupPrinter(self, event):
        self.presenter.setupPrinter()
        event.Skip()
        